package cn.moningxi.service.impl;

import cn.moningxi.bean.CustomerLoginLog;
import cn.moningxi.mapper.CustomerLoginLogMapper;
import cn.moningxi.service.CustomerLoginLogService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@Service
public class CustomerLoginLogServiceImpl implements CustomerLoginLogService {

    @Autowired
    private CustomerLoginLogMapper customerLoginLogMapper;

    @Override
    public CustomerLoginLog selectByPrimaryKey(Integer loginId) {
        return customerLoginLogMapper.selectByPrimaryKey(loginId);
    }

    @Override
    public List<CustomerLoginLog> queryAll(Integer pageNum) {
        PageHelper.startPage(pageNum, 5);
        return customerLoginLogMapper.queryAll();
    }

    @Override
    public List<CustomerLoginLog> queryCustomerLoginLogByName(@PathVariable("nameInfo") String nameInfo, @PathVariable("beginTime") String beginTime, @PathVariable("endTime") String endTime, @PathVariable("pageNum") Integer pageNum) {
        PageHelper.startPage(pageNum, 5);
        return customerLoginLogMapper.queryCustomerLoginLogByName(nameInfo, beginTime, endTime);
    }

    /**
     * 插入登录日志信息
     *
     * @param customerLoginLog
     */
    @Override
    public void insert(CustomerLoginLog customerLoginLog) {
        customerLoginLogMapper.insert(customerLoginLog);
    }
}
